#!/usr/bin/env python
from misc.utility.scons_hints import *

from platform_ios_builders import generate_bundle

from platform_methods import combine_libs_apple_embedded

Import("env")

ios_lib = [
    "device_metrics.mm",
    "display_layer_ios.mm",
    "display_server_ios.mm",
    "godot_view_ios.mm",
    "main_ios.mm",
    "os_ios.mm",
]

env_ios = env.Clone()
ios_lib = env_ios.add_library("ios", ios_lib)

# (iOS) Enable module support
env_ios.Append(CCFLAGS=["-fmodules", "-fcxx-modules"])

combine_command = env_ios.CommandNoCache(
    "#bin/libgodot" + env_ios["LIBSUFFIX"], [ios_lib] + env_ios["LIBS"], env.Run(combine_libs_apple_embedded)
)

if env["generate_bundle"]:
    env.AlwaysBuild(env.CommandNoCache("generate_bundle", combine_command, env.Run(generate_bundle)))
